<template>
  <li class="v-side-menu-item-group">
    <div class="v-side-menu-item-group__title" :style="{ paddingLeft: levelPadding + 'px' }">
      <template v-if="!$slots.title">{{title}}</template>
      <slot v-else name="title"></slot>
    </div>
    <ul>
      <slot></slot>
    </ul>
  </li>
</template>

<script>
  export default {
    name: 'VSideMenuItemGroup',
    componentName: 'VSideMenuItemGroup',
    props: {
      title: {
        type: String,
      },
    },
    data() {
      return {
        paddingLeft: 20,
      };
    },
    computed: {
      levelPadding() {
        let padding = 10;
        let parent = this.$parent;
        while (parent && parent.$options.componentName !== 'VSideMenu') {
          if (parent.$options.componentName === 'VSideSubmenu') {
            padding += 24;
          }
          parent = parent.$parent;
        }
        if (padding === 10) padding = 24;
        return padding;
      },
    },
  };
</script>

